package config

import (
    "ebbflow/pkg/crypto"
    "encoding/json"
    "fmt"
    "io/ioutil"
)

type ThresholdBLSPublicConfig struct {
    ThresholdPK crypto.G1   `json:"threshold_pk"`
    PKs         []crypto.G1 `json:"pks"`
}

type ThresholdBLSPrivateConfig struct {
    NodeID int        `json:"node_id"`
    SK     crypto.ZR  `json:"sk"`
}

func LoadThresholdBLSPublicConfig(path string) (*ThresholdBLSPublicConfig, error) {
    data, err := ioutil.ReadFile(path)
    if err != nil { return nil, fmt.Errorf("read public bls config: %w", err) }
    var cfg ThresholdBLSPublicConfig
    if err := json.Unmarshal(data, &cfg); err != nil { return nil, fmt.Errorf("unmarshal public bls config: %w", err) }
    return &cfg, nil
}

func LoadThresholdBLSPrivateConfig(path string) (*ThresholdBLSPrivateConfig, error) {
    data, err := ioutil.ReadFile(path)
    if err != nil { return nil, fmt.Errorf("read private bls config: %w", err) }
    var cfg ThresholdBLSPrivateConfig
    if err := json.Unmarshal(data, &cfg); err != nil { return nil, fmt.Errorf("unmarshal private bls config: %w", err) }
    return &cfg, nil
}






